
#ifndef _NNDEPLOY_THREAD_POOL_OPENMP_H_
#define _NNDEPLOY_THREAD_POOL_OPENMP_H_

#include "nndeploy/base/macro.h"

#ifdef ENABLE_NNDEPLOY_OPENMP

#include <openmp.h>

#if OpenMP_CXX_VERSION_MAJOR >= 3
#define NNDEPLOY_OPENMP_PARALLEL_FOR_COLLAPSE_(t) NNDEPLOY_PRAGMA(NNDEPLOY_OPENMP parallel for collapse(t))
#else
#define NNDEPLOY_OPENMP_PARALLEL_FOR_COLLAPSE_(t) NNDEPLOY_PRAGMA(NNDEPLOY_OPENMP parallel for)
#endif
#define NNDEPLOY_OPENMP_PARALLEL_FOR_ NNDEPLOY_PRAGMA(NNDEPLOY_OPENMP parallel for)
#define NNDEPLOY_OPENMP_PARALLEL_FOR_GUIDED_ NNDEPLOY_PRAGMA(NNDEPLOY_OPENMP parallel for)
#define NNDEPLOY_OPENMP_PARALLEL_FOR_DYNAMIC_ NNDEPLOY_PRAGMA(NNDEPLOY_OPENMP parallel for schedule(dynamic))
#define NNDEPLOY_OPENMP_SECTION_ NNDEPLOY_PRAGMA(NNDEPLOY_OPENMP section)
#define NNDEPLOY_OPENMP_PARALLEL_SECTIONS_ \
  NNDEPLOY_PRAGMA(NNDEPLOY_OPENMP parallel sections)
#define NNDEPLOY_OPENMP_CORES_ (NNDEPLOY_OPENMP_get_num_procs())
#define NNDEPLOY_OPENMP_MAX_THREADS_NUM_ (NNDEPLOY_OPENMP_get_max_threads())
#define NNDEPLOY_OPENMP_TID_ (NNDEPLOY_OPENMP_get_thread_num())
#define NNDEPLOY_OPENMP_SET_THREADS_(t) (NNDEPLOY_OPENMP_set_num_threads(t))

#else

#define NNDEPLOY_OPENMP_PARALLEL_FOR_
#define NNDEPLOY_OPENMP_PARALLEL_FOR_GUIDED_
#define NNDEPLOY_OPENMP_PARALLEL_FOR_DYNAMIC_
#define NNDEPLOY_OPENMP_PARALLEL_FOR_COLLAPSE_(t)
#define NNDEPLOY_OPENMP_SECTION_
#define NNDEPLOY_OPENMP_PARALLEL_SECTIONS_
#define NNDEPLOY_OPENMP_CORES_ (1)
#define NNDEPLOY_OPENMP_MAX_THREADS_NUM_ (1)
#define NNDEPLOY_OPENMP_TID_ (0)
#define NNDEPLOY_OPENMP_SET_THREADS_(t)

#endif  // _OPENMP

#endif  // _NNDEPLOY_THREAD_POOL_OPENMP_H_
